package com.inews.business.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

// TODO: Auto-generated Javadoc
/**
 * 用户角色关系实体.
 */
@Entity
@Table(name="tbl_sys_user_role")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TblSysUserRole implements Serializable{
	
	private static final long serialVersionUID = 3858125794616531577L;
	
	/** The version. */
	private Long version;

	/** Id. */
	private Long id;
	
	/** 用户. */
	private TblSysUser user;
	
	/** 角色. */
	private TblSysRole role;
	
	
	public TblSysUserRole() {
	}

	public TblSysUserRole(TblSysUser user, TblSysRole role) {
		this.user = user;
		this.role = role;
	}

	@Version
	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, optional=false)    
	@JoinColumn(name="user_id")
	public TblSysUser getUser() {
		return user;
	}

	public void setUser(TblSysUser user) {
		this.user = user;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, optional=false)    
	@JoinColumn(name="role_id")
	public TblSysRole getRole() {
		return role;
	}

	public void setRole(TblSysRole role) {
		this.role = role;
	}

	
}
